package com.wms.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

@Data
@ApiModel("自动触发设置")
public class Set {

    @ApiModelProperty(hidden = true)
    String categoryCodesStr;
    @ApiModelProperty(hidden = true)
    int id;

    @ApiModelProperty("用户id,当前登录人的ID")
    int userId;

    @NotNull(message = "关闭类型不能为空")
    @Range(min = 1, max = 2, message = "关闭类型为1或2")
    @ApiModelProperty("关闭类型：1 关闭自动请购 2 关闭自动加工")
    int type;

    @NotNull(message = "关闭的类别编码不能为空")
    @ApiModelProperty("关闭的类别编码集合")
    List<String> categoryCodes;

    public void parseCategoryCodes() {
        if (categoryCodesStr != null) {
            this.categoryCodes = Arrays.asList(categoryCodesStr.split(","));
        }
    }
}
